<?php
/**
 * Initialize the options before anything else. 
 */
add_action( 'admin_init', '_custom_theme_options', 1 );


function _custom_theme_options() {
  
  /**
   * Get a copy of the saved settings array. 
   */
  $saved_settings = get_option( 'option_tree_settings', array() );
  
  /**
   * Create a custom settings array that we pass to 
   * the OptionTree Settings API Class.
   */
  $custom_settings = array(
    'contextual_help' => array(
	      'content'       => array( 
	        array(
	          'id'        => 'general_help',
	          'title'     => 'General',
	          'content'   => '<p>Help content goes here!</p>'
	        )
	      ),
	      'sidebar'       => '<p>Sidebar content goes here!</p>'
    ),
    'sections'        => array(
	      array(
	        'title'       => 'Header',
	        'id'          => 'general_default'
	      ),
	      array(
	        'title'       => 'Footer',
	        'id'          => 'footer'
	      ),
		  array(
	        'title'       => 'Social',
	        'id'          => 'social'
	      ),
	      array(
	        'title'       => 'Blog',
	        'id'          => 'blog'
	      ),
		  array(
	        'title'       => 'Search Slider',
	        'id'          => 'search-slider'
	      ),
		  array(
	        'title'       => 'General',
	        'id'          => 'general'
	      ),
	      array(
	        'title'       => 'Contact',
	        'id'          => 'contact'
	      )	     
    ),
    'settings'        => array(
		  array(
			'label'       => 'Logo',
			'id'          => 'logo',
			'type'        => 'upload',
			'desc'        => 'Upload the logo of your website here.',
			'std'         => '',
			'rows'        => '',
			'post_type'   => '',
			'taxonomy'    => '',
			'class'       => '',
			'section'     => 'general_default'
		  ),
		  array(
			'label'       => 'Favicon',
			'id'          => 'favicon',
			'type'        => 'upload',
			'desc'        => 'Upload your favicon in PNG format.',
			'std'         => '',
			'rows'        => '',
			'post_type'   => '',
			'taxonomy'    => '',
			'class'       => '',
			'section'     => 'general_default'
		  ),
		  array(
            'label'       => 'Phone Number:',
            'id'          => 'phone_number',
            'type'        => 'text',
            'desc'        => 'Add your Phone Number here it will be displayed in Header. For Example: 123-345-5678',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'general_default'
          ),
		  array(
            'label'       => 'Email',
            'id'          => 'header_email',
            'type'        => 'text',
            'desc'        => 'Add your email address that will be displayed in Header.',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'general_default'
          ),		  
		  array(			
			'label'       => 'Footer Logo',
			'id'          => 'footer_logo',
			'type'        => 'upload',
			'desc'        => 'Add small logo of your website for footer.',
			'std'         => '',
			'rows'        => '',
			'post_type'   => '',
			'taxonomy'    => '',
			'class'       => '',
			'section'     => 'footer'
          ),
		  array(			
			'label'       => 'Copyright Text',
			'id'          => 'copyright_text',
			'type'        => 'text',
			'desc'        => 'Add the copyright text.',
			'std'         => '',
			'rows'        => '',
			'post_type'   => '',
			'taxonomy'    => '',
			'class'       => '',
			'section'     => 'footer'
          ),
		  array(			
			'label'       => 'Developed By Text',
			'id'          => 'developed_by_text',
			'type'        => 'text',
			'desc'        => 'Text here will appear on the left bottom of footer.',
			'std'         => '',
			'rows'        => '',
			'post_type'   => '',
			'taxonomy'    => '',
			'class'       => '',
			'section'     => 'footer'
          ),
		  array(
            'label'       => 'Twitter URL',
            'id'          => 'twitter_url',
            'type'        => 'text',
            'desc'        => '',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'social'
          ),
		  array(
            'label'       => 'Facebook URL',
            'id'          => 'facebook_url',
            'type'        => 'text',
            'desc'        => '',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'social'
          ),
		  array(
            'label'       => 'Blogger URL',
            'id'          => 'blogger_url',
            'type'        => 'text',
            'desc'        => '',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'social'
          ),
		  array(
            'label'       => 'Picasa URL',
            'id'          => 'picasa_url',
            'type'        => 'text',
            'desc'        => '',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'social'
          ),
		  array(
            'label'       => 'Flickr URL',
            'id'          => 'flickr_url',
            'type'        => 'text',
            'desc'        => '',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'social'
          ),
		  array(
            'label'       => 'RSS URL',
            'id'          => 'rss_url',
            'type'        => 'text',
            'desc'        => '',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'social'
          ),
		  array(
            'label'       => 'Blog Page Title',
            'id'          => 'blog_title',
            'type'        => 'text',
            'desc'        => '',
            'std'         => 'News',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'blog'
          ),
		  array(
            'label'       => 'Blog Page Sub Title',
            'id'          => 'blog_sub_title',
            'type'        => 'text',
            'desc'        => '',
            'std'         => 'Market Updates',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'blog'
          ),
		  array(
            'label'       => 'Minimum Value',
            'id'          => 'min_val',
            'type'        => 'text',
            'desc'        => 'Minimum Possible Value. No commas allowed.',
            'std'         => '0',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'search-slider'
          ),
		  array(
            'label'       => 'Maximum Value',
            'id'          => 'max_val',
            'type'        => 'text',
            'desc'        => 'Maximum Possible Value. No commas allowed.',
            'std'         => '1000000',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'search-slider'
          ),
		  array(
            'label'       => 'Smaller Value - For Initial Selected Range',
            'id'          => 'ini_min_val',
            'type'        => 'text',
            'desc'        => 'No commas allowed.',
            'std'         => '100000',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'search-slider'
          ),
		  array(
            'label'       => 'Greater Value - For Initial Selected Range',
            'id'          => 'ini_max_val',
            'type'        => 'text',
            'desc'        => 'No commas allowed.',
            'std'         => '500000',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'search-slider'
          ),
		  array(
            'label'       => 'Step Value',
            'id'          => 'step',
            'type'        => 'text',
            'desc'        => 'No commas allowed.',
            'std'         => '5000',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'search-slider'
          ),
		  array(
        	'label'       => 'Hide slider on search results',
        	'id'          => 'hide_slider',
        	'type'        => 'checkbox',
        	'desc'        => 'Do you want to hide homepage slider on search results ?',
        	'choices'     => array(
          						array (
            						'label'       => 'Yes',
            						'value'       => 'Yes'
          							)
        						),
        	'std'         => '',
        	'rows'        => '',
        	'post_type'   => '',
        	'taxonomy'    => '',
        	'class'       => '',
        	'section'     => 'general'
      	  ),
		  array(
        	'label'       => 'Skip slider entries from list of entries listed below slider ?',
        	'id'          => 'skip_prop',
        	'type'        => 'checkbox',
        	'desc'        => 'Do you want to skip the properties listed in Homepage Slider from properties listed below slider ?',
        	'choices'     => array(
          						array (
            						'label'       => 'Yes',
            						'value'       => 'Yes'
          							)
        						),
        	'std'         => '',
        	'rows'        => '',
        	'post_type'   => '',
        	'taxonomy'    => '',
        	'class'       => '',
        	'section'     => 'general'
      	  ),
		  array(
        	'label'       => 'Do you want to use lightbox ?',
        	'id'          => 'lightbox',
        	'type'        => 'checkbox',
        	'desc'        => 'Do you want the propery image on home and listing pages to open in lightbox ?',
        	'choices'     => array(
          						array (
            						'label'       => 'Yes',
            						'value'       => 'Yes'
          							)
        						),
        	'std'         => '',
        	'rows'        => '',
        	'post_type'   => '',
        	'taxonomy'    => '',
        	'class'       => '',
        	'section'     => 'general'
      	  ),
		  array(
        	'label'       => 'Hide Ribbons on property image ?',
        	'id'          => 'hide_ribbons',
        	'type'        => 'checkbox',
        	'desc'        => 'Do you want to hide ribbons on bottom left corner of properties images ?',
        	'choices'     => array(
          						array (
            						'label'       => 'Yes',
            						'value'       => 'Yes'
          							)
        						),
        	'std'         => '',
        	'rows'        => '',
        	'post_type'   => '',
        	'taxonomy'    => '',
        	'class'       => '',
        	'section'     => 'general'
      	  ),		  
		  array(
            'label'       => 'Currency Sign',
            'id'          => 'currency_sign',
            'type'        => 'text',
            'desc'        => 'Specify your currency sign. For Example: $',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'general'
          ),
		  array(
            'label'       => 'Measurement Unit',
            'id'          => 'unit',
            'type'        => 'text',
            'desc'        => 'Specify your measurement unit. Example: Sq Ft',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'general'
          ),
		  array(
	        'label'       => 'How many properties per page',
	        'id'          => 'properties_per_page',
	        'type'        => 'select',
	        'desc'        => '',
	        'choices'     => array(
		          array(
		            'label'       => '2',
		            'value'       => '2'
		          ),
		          array(
		            'label'       => '4',
		            'value'       => '4'
		          ),
				  array(
		            'label'       => '6',
		            'value'       => '6'
		          ),
				  array(
		            'label'       => '8',
		            'value'       => '8'
		          ),
				  array(
		            'label'       => '10',
		            'value'       => '10'
		          )         
	        ),
	        'std'         => '4',
	        'rows'        => '',
	        'post_type'   => '',
	        'taxonomy'    => '',
	        'class'       => '',
	        'section'     => 'general'
	      ),
		  array(
			'label'       => 'Banner Image',
			'id'          => 'banner_image',
			'type'        => 'upload',
			'desc'        => 'Upload the banner image here. Banner Image should have 715px width and 143px height.',
			'std'         => '',
			'rows'        => '',
			'post_type'   => '',
			'taxonomy'    => '',
			'class'       => '',
			'section'     => 'general'
		  ),
		  array(
            'label'       => 'Banner Link URL',
            'id'          => 'banner_link',
            'type'        => 'text',
            'desc'        => 'Provide target link for Banner.',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'general'
          ),
		  array(
            'label'       => 'Target Email',
            'id'          => 'company_email',
            'type'        => 'text',
            'desc'        => 'Add your Email address that will receive contact form messages.',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'contact'
          ),
		  array(
            'label'       => 'Map Latitude',
            'id'          => 'map_latitude',
            'type'        => 'text',
            'desc'        => 'You can find your Latitude and Longitude using this link. http://itouchmap.com/latlong.html',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'contact'
          ),
		  array(
            'label'       => 'Map Longitude',
            'id'          => 'map_longitude',
            'type'        => 'text',
            'desc'        => 'You can find your Latitude and Longitude using this link. http://itouchmap.com/latlong.html',
            'std'         => '',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'contact'
          ),
		  array(
            'label'       => 'Map Zoom Level',
            'id'          => 'map_zoom_level',
            'type'        => 'text',
            'desc'        => 'Example: 17',
            'std'         => '17',
            'rows'        => '',
            'post_type'   => '',
            'taxonomy'    => '',
            'class'       => '',
			'section'     => 'contact'
          )
    )
  );
  
  /* settings are not the same update the DB */
  if ( $saved_settings !== $custom_settings ) {
    update_option( 'option_tree_settings', $custom_settings ); 
  }
  
}